{extend name="default/base/base_member" /}
{block name="member_main"}

<div class="dsm-default-form fl w-12">
    <form method="post" action="" id="address_form">
        <dl>
            <dt>{$Think.lang.consignee}：</dt>
            <dd>
                <span class="w400">
                    <input type="text" class="text" maxlength="20" name="true_name" value="{$address.address_realname}">
                </span>
            </dd>
        </dl>
        <dl>
            <dt>{$Think.lang.area}：</dt>
            <dd>
                <span class="w400">
                    <div>
                        <input type="hidden" value="{$address.city_id|default=''}" name="city_id" id="_area_1">
                        <input type="hidden" value="{$address.area_id|default=''}" name="area_id" id="_area_2">
                        <input type="hidden" name="area_info" id="region" value="{$address.area_info|default=''}"/>
                    </div>
                </span>
            </dd>
        </dl>
        <dl>
            <dt>{$Think.lang.street_address}：</dt>
            <dd>
                <span class="w400">
                    <input type="text" class="text" maxlength="20" name="address" value="{$address.address_detail}" onkeyup="local.search($(this).val());">
                </span>
            </dd>
        </dl>
        <dl>
            <dt>{$Think.lang.phone_number}：</dt>
            <dd>
                <span class="w400">
                    <input type="text" class="text" maxlength="20" name="tel_phone" value="{$address.address_tel_phone}">
                </span>
            </dd>
        </dl>
        <dl>
            <dt>手机号码：</dt>
            <dd>
                <span class="w400">
                    <input type="text" class="text" maxlength="20" name="mob_phone" value="{$address.address_mob_phone}">
                </span>
            </dd>
        </dl>

        <dl>
            <dt>{$Think.lang.real_name}：</dt>
            <dd>
                <span class="w400">
                    <input type="text" class="text" maxlength="20" name="real_name" value="{$address.real_name}">
                </span>
            </dd>
        </dl>
        <dl>
            <dt>{$Think.lang.id_card_no}：</dt>
            <dd>
                <span class="w400">
                    <input type="text" class="text" maxlength="20" name="id_card_no" value="{$address.id_card_no}">
                </span>
            </dd>
        </dl>
        <dl>
            <dt>{$Think.lang.id_card_front}：</dt>
            <dd>
                <span class="w800">
                    {if $address.id_card_front!= ''}
                    <div class="preview-img w80">
                        <img src="{$address.id_card_front}">
                    </div>
                    {/if}
                    <input type="hidden" class="text id_card_front" name="id_card_front" value="{$address.id_card_front}">
                    <span id="id_card_front"></span>
                </span>
            </dd>
        </dl>
        <dl>
            <dt>{$Think.lang.id_card_back}：</dt>
            <dd>
                <span class="w800">
                    {if $address.id_card_back != ''}
                    <div class="preview-img w80">
                        <img src="{$address.id_card_back}">
                    </div>
                    {/if}
                    <input type="hidden" class="text id_card_back" name="id_card_back" value="{$address.id_card_back}">
                    <span id="id_card_back"></span>
                </span>
            </dd>
        </dl>

        <dl>
            <dt>{$Think.lang.default}：</dt>
            <dd>
                <input type="checkbox" class="checkbox vm mr5" name="is_default" id="is_default" value="1" {if $address.address_is_default eq '1'}checked="checked"{/if} />
                <label for="is_default">{$Think.lang.set_default_shipping_address}</label>
            </dd>
        </dl>
        <dl style="display: none;">
            <dt>{$Think.lang.map_location}：</dt>
            <dd>
                <input name="longitude" id="longitude" value="{$address.address_longitude}" type="hidden" />
                <input name="latitude" id="latitude" value="{$address.address_latitude}" type="hidden" />
                <div id="allmap" style="width:530px;height: 350px;margin-top: 20px"></div>
            </dd>
        </dl>
        <dl class="bottom">
            <dt></dt>
            <dd>
                <label class="submit-border">
                    <input type="submit" class="submit" value="{$Think.lang.save_changes}">
                </label>
            </dd>
        </dl>
    </form>
</div>
<link rel="stylesheet" href="/static/plugins/easyUpload/main.css">
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote.js" defer></script>
<script src="/static/plugins/easyUpload/easyUploader.js" ></script>
<style>
    .preview-img img{
        max-width: 100%;
    }
    .preview-img{
        display: inline-block;
    }
    .preview-img ~ span {
        vertical-align: middle;
    }
</style>
<script>
var uploader = easyUploader({
    id: "id_card_back",
    accept: '.jpg,.png,.jpeg,.gif',
    action: "{:url('member/upload')}",        // 文件上传接口successKey
    dataFormat: 'formData',
    name: 'file',
    maxCount: 1,
    maxSize: 3,
    autoUpload: true,
    multiple: false,
    imgIdInput: '',  // 图片ID存储位置
    imgIdKey: 'msg.id',       // 图片ID键值
    imgUrlInput: '.id_card_back',            // 图片链接存储位置
    imgUrlKey: 'msg.url',      // 图片URL键值
    successKey: 'code', //标识上传成功的key 
    successValue: 1, //标识上传成功对应的value 
    imgList: [],
    headers: {
    },
    data: null,
    beforeUpload: function(file, data, args) {
        // data.append('token', '387126b0-7b3e-4a2a-86ad-ae5c5edd0ae6TT'); //上传方式为formData时
        // data.id = file.id; //上传方式为base64时
    },
    onChange: function(fileList) {
        /* input选中时触发 */
    },
    onRemove: function(removedFile) {
        // 删除回调
        console.log('onRemove', removedFile);
    },
    onSuccess: function(res) {
        console.log('onSuccess', res);
    },
    onError: function(err) {
        console.log('onError', err);
    },
});
var uploader2 = easyUploader({
    id: "id_card_front",
    accept: '.jpg,.png,.jpeg,.gif',
    action: "{:url('member/upload')}",        // 文件上传接口successKey
    dataFormat: 'formData',
    name: 'file',
    maxCount: 1,
    maxSize: 3,
    autoUpload: true,
    multiple: false,
    imgIdInput: '',  // 图片ID存储位置
    imgIdKey: 'msg.id',       // 图片ID键值
    imgUrlInput: '.id_card_front',            // 图片链接存储位置
    imgUrlKey: 'msg.url',      // 图片URL键值
    successKey: 'code', //标识上传成功的key 
    successValue: 1, //标识上传成功对应的value 
    imgList: [],
    headers: {
    },
    data: null,
    beforeUpload: function(file, data, args) {
        // data.append('token', '387126b0-7b3e-4a2a-86ad-ae5c5edd0ae6TT'); //上传方式为formData时
        // data.id = file.id; //上传方式为base64时
    },
    onChange: function(fileList) {
        /* input选中时触发 */
    },
    onRemove: function(removedFile) {
        // 删除回调
        console.log('onRemove', removedFile);
    },
    onSuccess: function(res) {
        console.log('onSuccess', res);
    },
    onError: function(err) {
        console.log('onError', err);
    },
});
</script>

<script src="{$Think.PLUGINS_SITE_ROOT}/mlselection.js"></script>
<script type="text/javascript" src="{$Think.HTTP_TYPE}api.map.baidu.com/api?v=2.0&ak={$baidu_ak}"></script>
<script>
    var local;
    var map;
    var lst_name='';
            $(function () {
                $("#region").sc_region();
            });
    $(document).ready(function () {
        $('#address_form').validate({
            submitHandler: function (form) {
                {if isset($popup) && $popup}
                sc_ajaxpost('address_form','parent_reload','{:url('Memberaddress/index')}');
                {else}
                sc_ajaxpost('address_form','url','{:url('Memberaddress/index')}');
                {/if}
            },
            rules: {
                true_name: {
                    required: true
                },
                address: {
                    required: true
                },
                tel_phone: {
                    required: check_phone,
                    minlength: 6,
                    maxlength: 20
                },
                mob_phone: {
                    required: check_phone,
                    minlength: 11,
                    maxlength: 11,
                    digits: true
                }
            },
            messages: {
                true_name: {
                    required: '{$Think.lang.please_fill_name_consignee}'
                },
                address: {
                    required: '{$Think.lang.please_fill_address_consignee}'
                },
                tel_phone: {
                    required: '{$Think.lang.fill_least_one_phone}',
                    minlength: '{$Think.lang.please_correct_fill_phone_number}',
                    maxlength: '{$Think.lang.please_correct_fill_phone_number}'
                },
                mob_phone: {
                    required: '{$Think.lang.fill_least_one_phone}',
                    minlength: '{$Think.lang.please_fill_phone_number_correctly}',
                    maxlength: '{$Think.lang.please_fill_phone_number_correctly}',
                    digits: '{$Think.lang.please_fill_phone_number_correctly}'
                }
            }
        });
        function check_phone() {
            return ($('input[name="tel_phone"]').val() == '' && $('input[name="mob_phone"]').val() == '');
        }
    });
</script>


{/block}


